#include "Channel.h"
#include <stddef.h>
#include <stdlib.h>

Channel::Channel(int32_t fd, FDEvent events, handleFunc readCallback, handleFunc writeCallback, handleFunc destroyCallback, void *arg)
{
    this->m_fd = fd;
    this->m_events = (int)events;
    this->readCallback = readCallback;
    this->writeCallback = writeCallback;
    this->destroyCallback = destroyCallback;
    this->m_arg = arg;
}

void Channel::writeEventEnable(bool flag)
{   
    if (flag)
    {
        m_events |= static_cast<int>(FDEvent::WriteEvent);
    }
    else
    {
        m_events = m_events & ~static_cast<int>(FDEvent::WriteEvent);
    }
}

bool Channel::isWriteEventEnable()
{
    return m_events & static_cast<int>(FDEvent::WriteEvent);
}

